<!DOCTYPE html>
<html style="height: 100%">
<head>
    <meta charset="UTF-8">
    <title>图形</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

    <script type="text/javascript" src="../echartsjs/echarts.min.js"></script>
    <script src="../JQmobiscrol_2.5.2/dev/jquery-1.9.1.js"></script>

</head>

<body style="height: 100%; margin: 0">

<div id="container" style="height: 90%;width: 99%;border: 1px solid red"></div>


<script type="text/javascript">

var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;

var data1 = [];

    function Xz(){
         data1 = [];
            $.ajax({
                /*  url:"../jquery-easyui-1.6.7/demo/accordion/datagrid_data1.json",*/
                url: "http://192.168.0.200:7071/c/a",
                type: "GET",
                datatype: "json",
                success: function (data) {

                    for (let i = 0; i < data.length; i++) {
                          data1.push(data[i]["addr"]);
                    }
                    console.log("函数内层赋值之后的结果")
                    console.log(data1);
                }
            })
        return data1;
    };

console.log("外层调用函数时传出的结果")
console.log(Xz());
console.log(getUrlParam("name"));


//获取浏览器地址参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]);
    return null; //返回参数值
}

//获取浏览器地址参数（参数为中文）
function getRequest() {
    var url = window.location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            //就是这句的问题
            theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
            //之前用了unescape()
            //才会出现乱码
        }
    }
    return theRequest;
}

var parameter = getRequest();
var searchtxt = parameter['searchtxt'];//参数名



setTimeout(function(){

    console.log("外层调用函数二次调用")
    console.log(data1);
    console.log("睡眠结束")

app.config = {
    rotate: 90,
    align: 'left',
    verticalAlign: 'middle',
    position: 'insideBottom',
    distance: 50,
    onChange: function () {
        var labelOption = {
            normal: {
                rotate: app.config.rotate,
                align: app.config.align,
                verticalAlign: app.config.verticalAlign,
                position: app.config.position,
                distance: app.config.distance
            }
        };
        myChart.setOption({
            series: [{
                label: labelOption
            }, {
                label: labelOption
            }, {
                label: labelOption
            }, {
                label: labelOption
            }]
        });
    }
};

var labelOption = {
    normal: {
        show: true,
    /*    position: app.config.position,   */
        distance: app.config.distance,
        align: app.config.align,
        verticalAlign: app.config.verticalAlign,
        rotate: app.config.rotate,
        formatter: '{c}  {name|{a}}',
        fontSize: 14,
        rich: {
            name: {
                textBorderColor: '#fff'
            }
        }
    }
};

option = {
    color: ['#4cabce'],
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        }
    },

    calculable: true,
    xAxis: [
        {
            type: 'category',
            axisTick: {show: true},

            data:
            /*data1,*/
               ["1号定型机烫剪毛",'2号定型机','3','4','5','6','7','8','9','10','11','12'],

            axisLabel:{
                interval:0,//横轴信息全部显示
                rotate:-70,//-30度角倾斜显示
            }
        }
    ],
    yAxis: [
        {
            type: 'value'
        }
    ],
    series: [
        {
            name: '',
            type: 'bar',
            barGap: 0,
            label: labelOption,
            barWidth:30,
            data: [320, 332, 301, 334, 390,520,200,230,125,123,365,456]
        }

    ]
};


if (option && typeof option === "object") {
    myChart.setOption(option, true);
}

}, 100);

</script>
   </body>
</html>